{include file="public:header" /}
    <div style="margin: 0 auto">
        <div class="page-header">
            <h2 class="text-center">用户登录</h2>
            <p class="col-md-4"></p>
            <br>
            <form class="form-horizontal" method="post" id="login">
                <div class="form-group">
                    <label class="col-sm-4 control-label">手机号:</label>
                    <div class="col-sm-4">
                        <input type="text" name="tel" class="form-control" value="123456" id="tel" placeholder="tel">
                    </div>
                </div>

                <div class="form-group">
                    <label  class="col-sm-4 control-label">密码:</label>
                    <div class="col-sm-4">
                        <input type="password" name="password" class="form-control" value="123456" id="inputPassword4" placeholder="Password">
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-5 col-sm-8">
                        <button type="button" class="btn btn-primary" id="submit">登录</button>
                        &nbsp&nbsp&nbsp&nbsp
                        <a href="{:url('register')}" class="btn btn-primary">注册</a>
                    </div>
                </div>

                <div >
                    <div class="col-sm-offset-5 col-sm-4">
                    </div>
                </div>
            </form>

        </div>
    </div>

    <script type="text/javascript">
        $(function(){
            $('#submit').on('click',function(){
                //用ajax提交用户信息
                $.ajax({
                    type: 'post',
                    url: "{:url('loginCheck')}",
                    data: $('#login').serialize(),
                    dataType: 'json',
                    success: function(data){
                        switch (data.status)
                        {
                            case 1:  //登录成功跳到首页
                                alert(data.message);
                                window.location.href = "{:url('user/index')}";
                                break;
                            case 0:  //失败或验证不通过返回登录页
                            case -1:
                                alert(data.message);
                                window.location.back();
                                break;
                        }

                    }
                })
            })
        })
    </script>
{include file="public:footer" /}